/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.khk.lesson;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Jeroen
 */
@Entity
@Table(name = "postcode")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Postcode.findAll", query = "SELECT p FROM Postcode p"),
    @NamedQuery(name = "Postcode.findById", query = "SELECT p FROM Postcode p WHERE p.id = :id"),
    @NamedQuery(name = "Postcode.findByPostcode", query = "SELECT p FROM Postcode p WHERE p.postcode = :postcode"),
    @NamedQuery(name = "Postcode.findByNaam", query = "SELECT p FROM Postcode p WHERE p.naam = :naam"),
    @NamedQuery(name = "Postcode.findByUp", query = "SELECT p FROM Postcode p WHERE p.up = :up")})
public class Postcode implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 8)
    @Column(name = "Postcode")
    private String postcode;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "Naam")
    private String naam;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "Up")
    private String up;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "postcodeID")
    private Collection<Klant> klantCollection;

    public Postcode() {
    }

    public Postcode(Integer id) {
        this.id = id;
    }

    public Postcode(Integer id, String postcode, String naam, String up) {
        this.id = id;
        this.postcode = postcode;
        this.naam = naam;
        this.up = up;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPostcode() {
        return postcode;
    }

    public void setPostcode(String postcode) {
        this.postcode = postcode;
    }

    public String getNaam() {
        return naam;
    }

    public void setNaam(String naam) {
        this.naam = naam;
    }

    public String getUp() {
        return up;
    }

    public void setUp(String up) {
        this.up = up;
    }

    @XmlTransient
    public Collection<Klant> getKlantCollection() {
        return klantCollection;
    }

    public void setKlantCollection(Collection<Klant> klantCollection) {
        this.klantCollection = klantCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Postcode)) {
            return false;
        }
        Postcode other = (Postcode) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "be.khk.lesson.Postcode[ id=" + id + " ]";
    }
    
}
